import request from "@/axios/request";
import url from "@/axios/url";
const { mesUrl, adminUrl, commonserviceUrl, baseDataUrl, wmsUrl } = url();
// 导出url
export const exportUrl = `${mesUrl}mesProdOrder/export`;
// 导出url
export const exportUrlNew = `${mesUrl}mesProdOrder/exportNew`;
// 分页查询
export function getList(params = {}) {
  return request({
    url: `${mesUrl}mesProdOrder/selectList`,
    method: "get",
    params,
  });
}
export function getBomVersionList(params = {}) {
  return request({
    url: `${mesUrl}mesProdBom/getBomVersionList`,
    method: "get",
    params,
  });
}
// 新增
export function rowCreate(data = {}) {
  return request({
    url: `${mesUrl}mesProdOrder`,
    method: "post",
    data,
  });
}
// 修改
export function rowUpdate(data = {}) {
  return request({
    url: `${mesUrl}mesProdOrder`,
    method: "put",
    data,
  });
}

// 冻结/解冻
export function rowFreezeOrder(data = {}) {
  return request({
    url: `${mesUrl}mesProdOrder/freezeOrder`,
    method: "put",
    data,
  });
}
// 删除
export function rowDel(id) {
  return request({
    url: `${mesUrl}mesProdOrder/${id}`,
    method: "put",
  });
}
// 详情
export function rowDetail(id) {
  return request({
    url: `${mesUrl}mesProdOrder/info/${id}`,
    method: "get",
  });
}

// 查询工厂编码列表
export function getFactoryCodeList() {
  return request({
    url: `${adminUrl}baseFactoryModeling/select?level=3`,
    method: "get",
  });
}
// 查询虚实订单类型（无bom虚单，实单，bom需单）列表
export function getSimulatedTypeList() {
  return request({
    url: `${adminUrl}dict/type/simulated_type`,
    method: "get",
  });
}
// 查询生产订单类型：内销，外销，样机列表
export function getProdOrderTypeList() {
  return request({
    url: `${adminUrl}dict/type/prod_order_type`,
    method: "get",
  });
}
// 查询  0：自动倒冲，1：手动倒冲列表
export function getBackflushTypeList() {
  return request({
    url: `${adminUrl}dict/type/backflush_type`,
    method: "get",
  });
}
// 查询订单状态（未开始，进行中，已完成，待下发，已下发）列表
export function getProdOrderStatusList() {
  return request({
    url: `${adminUrl}dict/type/prod_order_status`,
    method: "get",
  });
}
// 查询订单状态（未开始，进行中，已完成，待下发，已下发）列表
export function getOrderStatusList() {
  return request({
    url: `${adminUrl}dict/type/prod_order_status`,
    method: "get",
  });
}
// 是否正在执行接口(0:否,1:是)
export function getIsRunningList() {
  return request({
    url: `${adminUrl}dict/type/yes_or_not`,
    method: "get",
  });
}
// 查询前置工单类型列表
export function getPrepositionTypeList() {
  return request({
    url: `${adminUrl}dict/type/order_preposition_type`,
    method: "get",
  });
}
// 查询条码规则下拉框
export function getOrderBarcodeRuleList() {
  return request({
    url: `${adminUrl}baseCodeStrategy/list`,
    // url: `${adminUrl}dict/type/prod_order_status`,
    method: "get",
  });
}
// BOM版本号下拉框
export function getBomVersionNumberList(params = {}) {
  // debugger;
  // console.log("22222", data);
  return request({
    url: `${mesUrl}mesProdBom/list`,
    method: "get",
    params,
  });
}
// 下发
export function rowGenerate(data = {}) {
  return request({
    url: `${mesUrl}mesProdOrder/orderGenerate`,
    method: "put",
    data,
  });
}
// 查询线体编码列表
export function getLineCodeList(params) {
  return request({
    url: `${adminUrl}baseFactoryModeling/children`,
    method: "get",
    params,
  });
}
// 查询线体编码列表
export function getLineCodeListNew(params) {
  return request({
    url: `${adminUrl}baseFactoryModeling/children`,
    method: "get",
    params,
  });
}
//根据订单id查询条码过站信息
export function orderTraceReportGetD(params) {
  return request({
    url: `${mesUrl}orderTraceReport/detail`,
    method: "get",
    params,
  });
}
export function salesDetail(params) {
  return request({
    url: `${mesUrl}mesSalesOrderDetail/list`,
    method: "get",
    params,
  });
}
/* 打印模板详情 */
export function printTemplateInfo(id = "") {
  return request({
    url: `${adminUrl}printTemplate/info/${id}`,
    method: "get",
  });
}
/* 批量获取打印数据信息 */
export function orderInfoGetBarcode(ids = "") {
  return request({
    url: `${mesUrl}mesProdOrder/selectListByIds/${ids}`,
    method: "get",
  });
}
//车间类型列表
export function getModelingTypeList() {
  return request({
    url: `${adminUrl}dict/type/modeling_type`,
    method: "get",
  });
}

// 根据线体获取工位
export function getStationCodeList(data = {}) {
  return request({
    url: `${mesUrl}mesProdOrder/getStationList`,
    method: "post",
    data,
  });
}
// 根据工位获取设备
export function getequipmentCodeList(params) {
  return request({
    url: `${adminUrl}commonBaseEquipmentModeling/list`,
    method: "get",
    params,
  });
}
export function reportOrderByProcess(data = {}) {
  debugger;
  return request({
    url: `${mesUrl}mesProdOrder/reportOrderByProcess`,
    method: "put",
    data,
  });
}
// 根据车间编码查询制造模型列表
export function getModelSetting(params) {
  return request({
    url: `${adminUrl}commonManufacturingModel`,
    // url: `http://localhost:10000/common-service/commonManufacturingModel`,
    method: "get",
    params,
  });
}

// 异常关结工单
export function abnormalClosureOrder(params = {}) {
  return request({
    url: `${mesUrl}mesProdOrder/abnormalClosureOrder`,
    method: "post",
    params,
  });
}

// 工厂建模-获取车间节点列表
export function getchildrenbytype(params = {}) {
  return request({
    url: `${adminUrl}baseFactoryModeling/children`,
    method: "get",
    params,
  });
}
// 工厂建模-获取子节点列表
export function getchildren(params = {}) {
  return request({
    url: `${adminUrl}baseFactoryModeling/children`,
    method: "get",
    params,
  });
}
// 根据优先级展示工单列表
export function getPageOrderListByPriority(params = {}) {
  return request({
    url: `${mesUrl}mesProdOrder/getPageOrderListByPriority`,
    method: "get",
    params,
  });
}
// 上移或下移行优先级
export function upOrDownPriority(params = {}) {
  return request({
    url: `${mesUrl}mesProdOrder/upOrDownPriority`,
    method: "post",
    params,
  });
}

export function batchOrderGenerate(params) {
  return request({
    url: `${mesUrl}mesProdOrder/batchOrderGenerate?ids=` + params,
    method: "get",
    params,
  });
}
export function freezeOrderBatch(params) {
  return request({
    url: `${mesUrl}mesProdOrder/freezeOrderBatch`,
    method: "post",
    data: params,
  });
}
export function thawOrderBatch(params) {
  return request({
    url: `${mesUrl}mesProdOrder/thawOrderBatch`,
    method: "post",
    data: params,
  });
}
export function getPickMaterials(id) {
  return request({
    url: `${mesUrl}mesProdOrder/getPickMaterials/${id}`,
    method: "get",
  });
}
export function getWareList(id) {
  return request({
    url: `${adminUrl}baseFactoryModeling/children?modelingCode=${id}&level=4&modelingType=1`,
    method: "get",
  });
}
export function getWareStock(data) {
  return request({
    url: `${wmsUrl}wmsInventorySn/getWareStock`,
    method: "post",
    data: data,
  });
}
export function saveMaterialList(data) {
  return request({
    url: `${mesUrl}mesProdOrder/saveMaterialList`,
    method: "post",
    data: data,
  });
}
